{{#if isShowingModal}}
  {{institutional-memory/wiki/url-list/add-dialog
    saveLink=(action "onSaveLink")
    cancelAddLink=(action (mut isShowingModal) false)
  }}
{{/if}}

{{#if listData.length}}
  <NachoTable
    class={{baseTableClass}}
    @tableConfigs={{tableConfigs}}
    @tableClass={{baseTableClass}}
  as |table|
  >
    {{#table.global}}
      <button
        class="{{baseTableClass}}__global-button"
        {{action "onAddLink"}}
      >
        {{fa-icon "plus"}} Add Link
      </button>
    {{/table.global}}
    {{#table.body as |body|}}
      {{#each listData as |docLink|}}
        {{#body.row}}
          <td class="nacho-table__cell {{baseTableClass}}__author-info">
            {{#let docLink.actor as |actor|}}
              {{#with actor.entityLink.link as |link|}}
                <DynamicLink @params={{link}}>
                  {{actor.username}}
                </DynamicLink>
              {{else}}
                {{actor.username}}
              {{/with}}
            {{/let}}
          </td>
          <td class="nacho-table__cell {{baseTableClass}}__date-info">
            {{moment-format (unix docLink.timestamp) "MM/DD/YYYY"}}
          </td>
          <td class="nacho-table__cell {{baseTableClass}}__link-info">
            <a href={{docLink.url}} target="_blank" rel="noopener">
              {{docLink.url}}
            </a>
          </td>
          <td class="nacho-table__cell {{baseTableClass}}__description-info">{{docLink.description}}</td>
          <td class="nacho-table__cell">
            <button
              class="{{baseTableClass}}__actions-button"
              {{action "onRemoveLink" docLink}}
            >
              {{fa-icon "trash"}}
            </button>
          </td>
        {{/body.row}}
      {{/each}}
    {{/table.body}}
  </NachoTable>

{{else if (eq listData.length 0)}}

  <EmptyState>
    <h3>Be the first one to add a link.</h3>
    <p>
      Note down documentation or wiki link to help the community better leverage the context
      {{if entityName (concat "of this " entityName)}}
    </p>
    <button
      class="nacho-button--large nacho-button--secondary"
      {{action "onAddLink"}}
    >
      {{fa-icon "plus"}}
      Add link
    </button>
  </EmptyState>

{{/if}}

